<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use log;


class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        //
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        // $schedule->command('inspire')
        //          ->hourly();

	$schedule->call(function () {
            $userPhones = Redis::smembers('userPhone');
	    foreach($userPhones as $userPhone){
		$order = Redis::hgetall('usecar:'.$userPhone);
		$time = time()-$order['created_at'];
		if($order['isAccept']==0 && $time > 1800){
			Log::info('order more than 30 mins'.$order['userPhone']);
		}
	    }
        })->everyThirtyMinutes();	
    }

    /**
     * Register the Closure based commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        require base_path('routes/console.php');
    }
}
